﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyFstCore.Services
{
    public class EfRepository : IRepository<Student>
    {
        private readonly DataContext dataContext;

        public EfRepository(DataContext dataContext)
        {
            this.dataContext = dataContext;
        }
        public void Add(Student newModel)
        {
            dataContext.students.Add(newModel);
            dataContext.SaveChanges();
        }

        public IEnumerable<Student> GetAll()
        {
           return dataContext.students.ToList();
        }

        public Student GetById(int id)
        {
            return dataContext.students.Find(id);
        }
    }
}
